package com.hu.hrm.feignclients;

import com.hu.hrm.fallback.RedisFeignClientFallbackFactory;
import com.hu.hrm.util.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
//FallbackFactory来开启熔断 Factory比之前好的：可以拿到错误信息
@FeignClient(value = "redis-server",fallbackFactory = RedisFeignClientFallbackFactory.class) //服务名去找redis-server
public interface RedisFeignClient {
    //设置值
    @PostMapping("/redis/set")  //完整的路径
    AjaxResult set(@RequestParam("key") String key, @RequestParam("value") String value);

    //获取值
    @GetMapping("/redis/get/{key}")
    AjaxResult get(@PathVariable("key") String key);

    //设置值（主要是多了过期时间）
    @PostMapping("/redis/setex")
    AjaxResult setex(@RequestParam("key") String key,@RequestParam("seconds") int seconds ,@RequestParam("value") String value);

}
